//
//  BookTableViewController.m
//  简书-发现
//
//  Created by mafeng on 16/8/1.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "BookTableViewController.h"
#import "BookTableViewCell.h"
#import "MFCyclmage.h"
#import "SelfSizeTool.h"
#define kTableViewCell @"reuse"
@interface BookTableViewController ()
@property (nonatomic, strong) NSArray *strArray;
@property (nonatomic, strong) NSArray *array;
@property (nonatomic, strong) NSArray *modelArray;
@end

@implementation BookTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.strArray = @[@"束仿写简书 <发现> 页面的tableView, 包括Header。输入框用button代替(数据使用假数据, 自己制作model数组)", @"束仿写简书 <发现> 页面的tableView, 包括Header", @"束仿写简书 <发现>"];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    self.array = @[@"0", @"1", @"2", @"3", @"4"];
    MFCyclmage *cyclemage = [[MFCyclmage alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 200)];
    [cyclemage setImageWithArray:_array];
    self.tableView.tableHeaderView = cyclemage;
    Book *book = [[Book alloc] initUserName:@"mafneg" Title:@"ios泛起" readNum:@"1023浏览" commentNum:@"10评论" likeNUm:@"10喜欢" date:@"12-11" time:@"10:36" labelButton:@"想法" userImageString:@"user"];
     Book *book1 = [[Book alloc] initUserName:@"gaopengfei" Title:@"　中国的文人，对于人生，──至少是对于社会现象，向来就多没有正视的勇气。我们的圣贤，本来早已教人“非礼勿视”的了。而这“礼”又非常" readNum:@"10203浏览" commentNum:@"10评论" likeNUm:@"10喜欢" date:@"12-11" time:@"10:36" labelButton:@"鲁大哥" userImageString:@"user"];
    self.modelArray = @[book, book1, book];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    BookTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewCell forIndexPath:indexPath];

    cell.titleLable.text = _strArray[indexPath.row];
    cell.rightImageView.image = [UIImage imageNamed:_array[indexPath.row]];
    [cell setBook:_modelArray[indexPath.row]];
    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
